// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Blue Block Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 4 : TYPE_BLUEBLOCK

// Function declarations
reserve function BlueBlock_DebugDraw
reserve function BlueBlock_DebugSpawn

// Static Values

// Tables

function BlueBlock_DebugDraw
	DrawSprite(0)
	DrawSprite(1)
	DrawSprite(2)
end function


function BlueBlock_DebugSpawn
	temp5 = 4
	temp4 = 0
	CallFunction(DebugMode_SpawnObject)
	object[arrayPos0].drawOrder = 4
	object[arrayPos0].groupID = GROUP_BLOCKS
end function


event ObjectMain
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		CallFunction(SpecialSetup_Function10)
	next
end event


event ObjectDraw
	if object.propertyValue > 0
		temp0 = SpecialSetup_value12
		temp0 >>= 3
		temp1 = object.propertyValue
		temp1 -= temp0
		switch temp1
		case 1
		case 3
			object.type = TypeName[Yellow Block]
		end switch
	end if
	CallFunction(SpecialSetup_Function9)
	DrawSpriteFX(0, FX_ROTATE, temp0, temp1)
	DrawSpriteXY(1, temp0, temp1)
	temp2 = object.rotation
	temp2 >>= 3
	temp2 += 2
	DrawSpriteFX(temp2, FX_ROTATE, temp0, temp1)
	object.type = TypeName[Blue Block]
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 126, 76)
	SpriteFrame(-10, -8, 20, 16, 151, 76)
	temp0 = 1
	temp1 = 1
	while temp1 < 100
		temp0 = 1
		while temp0 < 500
			SpriteFrame(-12, -12, 24, 24, temp0, temp1)
			temp0 += 25
		loop
		temp1 += 25
	loop
	foreach (TypeName[Blue Block], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].groupID = GROUP_BLOCKS
	next
	SetTableValue(TypeName[Blue Block], DebugMode_ObjCount, DebugMode_TypeTable)
	SetTableValue(BlueBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(BlueBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
	DrawSprite(1)
	DrawSprite(2)
end event

event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 126, 76)
	SpriteFrame(-10, -8, 20, 16, 151, 76)
	SpriteFrame(-12, -12, 24, 24, 1, 1)
end event
